package com.xq.shop.service.admin.impl;

import java.util.List;

import com.xq.shop.service.admin.IBaseService;
import com.xq.shop.vo.PageInfo;
import com.xq.shop.vo.SearchObject;

public abstract class  BaseService<T> implements IBaseService<T> {

	@Override
	public void delete(List<Long> ids) {
		getDAO().delete(ids);
	}

	@Override
	public List<T> get(List<Long> ids) {
		return getDAO().get(ids.toArray(new Long[0]));
	}

	@Override
	public T get(Long id) {
		return getDAO().get(id);
	}
	
	@Override
	public List<T> get(Long[] ids) {
		return getDAO().get(ids);
	}

	@Override
	public PageInfo<T> get(SearchObject search) {
		
		long total = getDAO().getCount(search);
		List<T> result = getDAO().get(search);
		return new PageInfo<T>(search, result, total);
	}

	public List<T> getAll(){
		return getDAO().getAll();
	}

	@Override
	public void save(T instance) {
		getDAO().save(instance);
	}

	@Override
	public void saveOrUpdate(T instance) {
		getDAO().saveOrUpdate(instance);
	}

	@Override
	public void update(T instance) {
		getDAO().update(instance);
	}
}
